<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ page import="DAO.AgendaDAO" %>
<%@ page import="beans.Agenda" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="jdbc.ConnectionFactory" %>
<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Agendamentos</title>
</head>
<body>
	<%
try {
	        Connection conexao = new ConnectionFactory().getConnection();
		 	PreparedStatement stmt = conexao.
	                 prepareStatement("select a.cd_agendamento, a.ds_agendamento_data_hora, a.ds_status_agendamento, "
	                		 + "s.ds_servico_nome, s.ds_servico_preco, p.ds_prestador_nome_fant "
	                		 + "from agendamento a, servico s, prestador p where a.cd_usuario = " + session.getAttribute("cod_usuario") +
	                		 ";");
	         ResultSet rs = stmt.executeQuery();
	         //<TABLE BORDER=2 CELLPADDING=2 bgcolor="red">
	         //<TR>
	         //<TD COLSPAN=2>Teste Nome Fantasia</TD>
	         //<TR>
	         //<TD>Servico Agendado</TD> <TD>dd/MM/yyyy hh:mm:ss</TD>
	         //</TR>
	         //</TABLE>
	         while (rs.next()){
	        	//VERIFICA O STATUS DO AGENDAMENTO
	        	 String color = new String();
	        	 if(rs.getInt("ds_status_agendamento")==1){
	        		 color = "yellow";
	        	 }
	        	 else if(rs.getInt("ds_status_agendamento")==2){
	        		 color = "green";
	        	 }
	        	 else{
	        		 color = "red";
	        	 }
	         %>
	         <table border=2 cellpadding=2 bgcolor="<%out.print(color);%>">
	         	<tr align="center">
	         		<td colspan=2><%out.println("<h3>" + rs.getString("ds_prestador_nome_fant") + "</h3>");%></td>
	         	</tr>
	         	<tr>
	         		<td><%out.print(rs.getString("ds_servico_nome"));%></td>
	         		<td><%out.print(rs.getString("ds_agendamento_data_hora"));%></td>
	         	</tr>
	         </table>
	         <%
	      	}
	         rs.close();
	         stmt.close();
	     } catch (SQLException e) {
	         throw new RuntimeException(e);
	     }
%>
</body>
</html>